package com.koron.order.LineHomepage.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.koron.bean.query.PageQuery;
import com.koron.order.LineHomepage.bean.VO.LineTripVO;
import com.koron.order.LineHomepage.bean.query.LineTripQuery;
import com.koron.order.LineHomepage.mapper.LineTripVOMapper;
import com.koron.order.LineHomepage.service.LineTripVOService;
import org.koron.ebs.mybatis.SessionFactory;
import org.koron.ebs.mybatis.TaskAnnotation;
import org.springframework.stereotype.Service;

import java.util.List;


/**
*
*/
@Service
public class LineTripVOServiceImpl implements LineTripVOService {

    @Override
    @TaskAnnotation("page")
    public PageInfo<LineTripVO> page(SessionFactory sessionFactory, LineTripQuery lineTripQuery, PageQuery pageQuery) {
        LineTripVOMapper mapper = sessionFactory.getMapper(LineTripVOMapper.class);
        PageHelper.startPage(pageQuery.getPage(),pageQuery.getPageSize(),pageQuery.getOrderBy());
        List<LineTripVO> page = mapper.page(lineTripQuery);
        return new PageInfo<LineTripVO>(page);
    }

    @Override
    @TaskAnnotation("getById")
    public LineTripVO getById(SessionFactory sessionFactory, String id) {
        LineTripVOMapper mapper = sessionFactory.getMapper(LineTripVOMapper.class);
        return mapper.getById(id);

    }

    @Override
    @TaskAnnotation("save")
    public LineTripVO save(SessionFactory sessionFactory, LineTripVO lineTripVO) {
        LineTripVOMapper mapper = sessionFactory.getMapper(LineTripVOMapper.class);
         mapper.save(lineTripVO);
        return lineTripVO;
    }

    @Override
    @TaskAnnotation("deleteLogic")
    public Boolean deleteLogic(SessionFactory sessionFactory,String id) {
        LineTripVOMapper mapper = sessionFactory.getMapper(LineTripVOMapper.class);
        return mapper.deleteLogic(id);
    }
}
